load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "task",
    srcs = [
        "etcd_queue.go",
        "etcd_service.go",
        "task.go",
        "task.pb.go",
        "task.pb.validate.go",
        "task.pb.zap.go",
        "util.go",
    ],
    importpath = "github.com/pachyderm/pachyderm/v2/src/internal/task",
    visibility = ["//src:__subpackages__"],
    deps = [
        "//src/internal/collection",
        "//src/internal/errors",
        "//src/internal/errutil",
        "//src/internal/log",
        "//src/internal/pachhash",
        "//src/internal/pctx",
        "//src/internal/taskchain",
        "//src/internal/uuid",
        "//src/internal/watch",
        "//src/protoextensions",
        "//src/task",
        "//src/version",
        "@com_github_cevaris_ordered_map//:ordered_map",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_golang_google_protobuf//encoding/protojson",
        "@org_golang_google_protobuf//proto",
        "@org_golang_google_protobuf//reflect/protoreflect",
        "@org_golang_google_protobuf//runtime/protoimpl",
        "@org_golang_google_protobuf//types/known/anypb",
        "@org_golang_x_sync//errgroup",
        "@org_golang_x_sync//semaphore",
        "@org_uber_go_zap//:zap",
        "@org_uber_go_zap//zapcore",
    ],
)

go_test(
    name = "task_test",
    srcs = [
        "etcd_queue_test.go",
        "etcd_service_test.go",
    ],
    embed = [":task"],
    deps = [
        "//src/internal/errors",
        "//src/internal/pctx",
        "//src/internal/require",
        "//src/internal/testetcd",
        "//src/internal/uuid",
        "//src/task",
        "@org_golang_google_protobuf//proto",
        "@org_golang_google_protobuf//types/known/anypb",
        "@org_golang_x_sync//errgroup",
    ],
)

filegroup(
    name = "protos",
    srcs = glob(["*.proto"]),
    visibility = ["//src:__pkg__"],
)
